﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DotNet.WebUI.Admin
{
    public partial class Login : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }          

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtYanZM.Text.ToLower() != Session["DingY.Validate"].ToString().ToLower())
                {
                    MessageBox("验证码不正确");
                    return;
                }
            }
            catch
            {
                MessageBox("验证码不正确");
                return;
            }

            if (string.IsNullOrEmpty(txtDengLDM.Text) || string.IsNullOrEmpty(txtMiM.Text))
            {
                MessageBox("请输入登录代码及密码");
            }
            else
            {
                string _Sql = @"SELECT Count(*)
                    FROM Users
                WHERE LoginID= '{0}'
	                and Pwd ='{1}' ";
                _Sql = string.Format(_Sql, txtDengLDM.Text, txtMiM.Text);

                if (Convert.ToInt32(ExecuteScalar(_Sql)) >= 1)
                {
                    Session["DingY.DemoUsers"] = txtDengLDM.Text;
                    Response.Redirect("Home.aspx?Operate=AdminExam");
                }
                else
                {
                    MessageBox("登录代码或密码错误");
                }
            }

        }
    }
}